<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>

<script type="text/javascript">
	var resGrid = null;
	var resDialog = null;
	$(function(){
		resGrid = $("#res_grid").ligerGrid({
				title : '资源列表',
                columns: [
                { display: '资源名', name: 'name',isSort : false },
                { display: '类型', name: 'type',isSort : false },
                { display: '值', name: 'value',isSort : false}, 
                { display: '所属模块', name: 'module',isSort : false },
                { display: '描述', name: 'description',isSort : false},
                {
                	display: '<a href="javascript:;" onclick="addResource()">添加资源</a>', 
                	name: 'id',
                	isAllowHide: false, 
                	isSort : false,
					render: function (record, rowindex, value, column){
					//this     这里指向grid
					//record   行数据
					//rowindex 行索引
					//value    当前的值，对应record[column.name]
					//column   列信息
						var html = '<a onclick="editResource(\''+ value + '\')" href="javascript:;">编辑</a>&nbsp;<a onclick="deleteResource(\''+ value + '\')" href="javascript:;">删除</a>'; 
						return html; 
					}
                }
                ], 
                pageSize:30,
                root :'list',
                record:'totalRecord',
                url: "/misc/admin/resourceGrid.htm", 
                width: '99%',height:'99%'
            });
	});
	
	function deleteResource(resourceId){
		$.ligerDialog.confirm('你真的要删除吗？', 
		function (yes){
			if(yes){
				$.post("/misc/admin/deleteResource.htm",{resourceId:resourceId},function(){
					resGrid.loadData();
				}); 
			}
		});
	}
	
	function editResource(id){
		resDialog = $.ligerDialog.open({ height: 350,width:600, url: "/misc/admin/editResource.htm?id="+id, isResize: false ,modal:true,title:'编辑资源'});
	}
	
	function addResource(){
		resDialog = $.ligerDialog.open({ height: 350,width:600, url: "/misc/admin/addResource.htm", isResize: false ,modal:true,title:'添加资源'});
		
	}
</script>
<div id="res_grid" style="margin:0; padding:0"></div>
